package LeetCode.month01.day30;

import java.util.Arrays;
import java.util.PriorityQueue;

public class No3634 {
    public static void main(String[] args) {
        System.out.println(minRemoval(new int[]{92,75,335,26,221,19,54},4));
    }
    public static int minRemoval(int[] nums, int k) {
        int n = nums.length;
        Arrays.sort(nums);
        int res = 0;
        int left=0;
        System.out.println(Arrays.toString(nums));
        for (int i = 0; i < n; i++) {
            if((long)nums[i]>(long)nums[left]*k){
                res = Math.max(i-left,res);
                while((long)nums[left]*k<(long)nums[i]){
                    left++;
                }
            }
        }
        return n-Math.max(res,n-left);
    }
}
